<?php $this->_extends('../_layouts/default_layout');?>
<?php $this->_block('contents');?>
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/jq.autocomplete.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.autocomplete.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/validator.js"></script>
<script type="text/javascript">
$(function(){
	$("#check_available_number").click(function(){
		if ( ! $("#warehouse_id").val())
		{
			alert("请先选择仓库！");
			return false;
		}
		var product_number = encodeURIComponent($(this).prev().prev().val());
		$.ajax({
			type:"get",
			url:"<?=url('Sales::Product/CheckNumberExists')?>&product_number=" + product_number + "&warehouse_id=" + $("#warehouse_id").val(),
			dataType:"json",
			success:
				function(data)
				{
					if (data == 1)
					{
						$("#wrong_product").html("产品编号有效");
					}
					else if (data == -1)
					{
						$("#wrong_product").html("请输入产品编号");
					}
					else
					{
						var _html = '';
						$.each(data,function(index, product){
							_html +='<span class=\'red\'>' + product + '不存在</span><br />';
						});
						$('#wrong_product').html(_html);
					}
				}
		});
	});				
})
</script>

<form action="<?=url('Sales::Product/MultiUpdateStatusSave')?>" method="post" onSubmit="return Validator.Validate(this,3);">
<table class="form_table">
<tr>
	<th>说明：</th>
	<td colspan="2">每个产品编号用回车分开</td>
</tr>
<tr>
	<th>仓库</th>
	<td colspan="2">
	<select name="warehouse_id" id="warehouse_id" dataType="Require" msg="请选择">
		<option value="">请选择</option>
		<?foreach ($warehouse as $w):?>
		<option value="<?=$w['id']?>"><?=$w['name']?></option>
		<?endforeach;?>
	</select>
	</td>
</tr>
<tr>
	<th>产品编号</th>
	<td>
		<textarea name="multi_product_basic_number" rows="10" cols="20" dataType="Require" msg="请输入编号"></textarea>
		<br />
		<input type="button" id="check_available_number" class="button" value="检查产品" />
	</td>
	<td id="wrong_product"></td>
</tr>
<tr>
	<th>销售状态</th>
	<td colspan="2">
		<select name="sales_status" id="sales_status" dataType="Require" msg="请选择">
		<option value="">请选择</option>
		<?php foreach (Q::ini('custom_flag/product_sales_status') as $pss ):?>
		<option value="<?=$pss['value']?>" style="color:#<?=$pss['color']?>"><?=$pss['name']?></option>
		<?php endforeach;?>
		</select>
	</td>
</tr>
<tr>
	<th>&nbsp;</th>
	<td colspan="2">
		<input type="submit" class="button" value="批量修改" />
	</td>
</tr>
</table>
</form>

<?php $this->_endblock();?>